package com.llb666.common.core.web.response;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
//import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * 全局通用响应对象.
 *
 * @author llb666
 */
@Getter
@Setter
//@Schema(description = "通用响应体")
public class BaseResponse implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 成功响应的code.
     */
    public static final Integer SUCCESS_CODE = 200;

    /**
     * 成功响应的msg.
     */
    protected static final String SUCCESS_MSG = "ok";

//    @Schema(description = "响应业务状态")
    protected Integer status;

//    @Schema(description = "响应消息")
    protected String msg;

    public BaseResponse() {
        this(SUCCESS_CODE, SUCCESS_MSG);
    }

    @JsonCreator
    public BaseResponse(@JsonProperty("status") Integer status,
                        @JsonProperty("msg") String msg) {
        this.status = status;
        this.msg = msg;
    }

    public static BaseResponse ok() {
        return new BaseResponse();
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "status='" + status + '\'' +
                ", msg='" + msg + '\'' +
                '}';
    }
}
